import type { LocationQueryValue } from 'vue-router';
import _ from 'lodash';

export default class RouteHelper {
  static queryValueToPlural = (filed: LocationQueryValue | Array<LocationQueryValue>): Array<string> => {
    if (!filed) {
      return [];
    }
    if (_.isArray(filed)) {
      return _.compact([...filed]);
    }
    return _.compact([filed]);
  };

  static queryValueToSingular = (filed: LocationQueryValue | Array<LocationQueryValue>): LocationQueryValue => {
    if (_.isArray(filed)) {
      return filed[0];
    }
    return filed;
  };
}
